on:
  release:
    types: [published]
name: Release workflow
jobs:
  composer:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: composer
      uses: docker://composer
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        args: install --no-interaction --prefer-dist --optimize-autoloader
    - name: warm cache
      uses: phpDocumentor/phar-ga@latest
      with:
        args: php bin/console cache:warmup --env=prod
    - name: build phar
      uses: phpDocumentor/phar-ga@latest
      with:
        args: box compile
    - name: sign phar
      uses: phpDocumentor/phar-ga@latest
      env:
        PASSPHRASE: ${{ secrets.PASSPHRASE }}
        SECRET_KEY: ${{ secrets.SECRET_KEY }}
      with:
        args: gpg --command-fd 0 --pinentry-mode loopback -u info@phpdoc.org --batch
          --detach-sign --output build/phpDocumentor.phar.asc build/phpDocumentor.phar
    - name: release phar
      uses: fnkr/github-action-ghr@v1
      env:
        GHR_PATH: build/
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
